﻿using System;
using Owin;

namespace Sharp.Platform.Owin.OAuth.Baidu.Extensions
{
    public static class BaiduAuthenticationExtensions
    {
        public static void UseBaiduAuthentication(this IAppBuilder app,
            BaiduAuthenticationOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }


            app.Use(typeof(AuthenticationMiddleware), app, options);
        }

        public static void UseBaiduAuthentication(this IAppBuilder app, string apiKey, string secretKey)
        {
              app.UseBaiduAuthentication(new BaiduAuthenticationOptions
            {
                ApiKey = apiKey,
                SecretKey = secretKey
            });
        }
    }
}